﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IHISCETeim.DAL;
using IHISCETeim.Model;
using IHISCETeim.Library;
using System.Data;

namespace IHISCETeim.BLL
{
    public  class FXFinanceLeaseController
    {
        public static int Add(FXFinanceLeaseInfo obj)
        {
            return FXFinanceLeaseDAL.Add(obj);
        }
        public static bool Delete(int FnncLsId)
        {
            return FXFinanceLeaseDAL.Delete(FnncLsId);
        }

        public static FXFinanceLeaseInfo GetById(int FnncLsId)
        {
            return CBO.FillObject<FXFinanceLeaseInfo>( FXFinanceLeaseDAL.GetById(FnncLsId));
        }
        public static DataTableCollection GetPagination(string WhereSql, int PageIndex, int PageSize, string Sort, ref int TotalCount)
        {
            return FXFinanceLeaseDAL.GetPagination(WhereSql, PageIndex, PageSize, Sort, ref  TotalCount);
        }
        public static string ImportFromExcel(string ContractNum, decimal LPaidRent, short LEvadePeriods, decimal LPaidPeriods,string SerNum, string lastRealName)
        {
            return FXFinanceLeaseDAL.ImportFromExcel(ContractNum, LPaidRent, LEvadePeriods, LPaidPeriods,SerNum, lastRealName);
        }
        public static bool Update(FXFinanceLeaseInfo obj)
        {
            return FXFinanceLeaseDAL.Update(obj);
        }

        public static void WSBUpdate(int id,string remark)
        {
             FXFinanceLeaseDAL.WSBUpdate(id,remark);
        }
        /// <summary>
        /// 获取各进度的数量
        /// </summary>
        /// <param name="alisename">如果是区域经理使用，则需传入其所属的经销商查询条件</param>
        /// <returns>
        ///     审核中 ,审核通过,待放款,已放款
        /// </returns>
        public static DataTable GetLeaseStatusCount(string alisename)
        {
            return FXFinanceLeaseDAL.GetLeaseStatusCount(alisename);
        }
        /// <summary>
        /// 获取最后更新日期
        /// </summary>
        /// <returns></returns>
        public static string GetLastRefresDate()
        {
            return FXFinanceLeaseDAL.GetLastRefresDate();
        }
        /// <summary>
        /// 未上报获取最后更新日期
        /// </summary>
        /// <returns></returns>
        public static string GetWSBLasRefresDate()
        {
            return FXFinanceLeaseDAL.GetWSBLasRefresDate();
        }
        /// <summary>
        /// 未上报数据导入
        /// </summary>
        /// <param name="AliasName">经销商</param>
        /// <param name="CustomerName">用户</param>
        /// <param name="SerialNumber">机号</param>
        /// <param name="SaleDate">销售日期</param>
        /// <param name="LContractAmount">合同价格</param>
        /// <returns></returns>
        public static string ImportFromExcelWeiShangBao(string AliasName, string CustomerName, string SerialNumber, string SaleDate, decimal LContractAmount)
        {
            return FXFinanceLeaseDAL.ImportFromExcelWeiShangBao(AliasName, CustomerName, SerialNumber, SaleDate, LContractAmount);
        }
        /// <summary>
        /// 未上报数据导入
        /// 1.先清楚所有以前的未上报
        /// </summary>
        /// <returns></returns>
        public static bool DeleteWeiShangBao()
        {
            return FXFinanceLeaseDAL.DeleteWeiShangBao();
        }
        /// <summary>
        /// 未上报列表
        /// </summary>
        /// <param name="WhereSql"></param>
        /// <param name="PageIndex"></param>
        /// <param name="PageSize"></param>
        /// <param name="Sort"></param>
        /// <param name="TotalCount"></param>
        /// <returns></returns>
        public static DataTableCollection FXFinanceLeaseWSBGetPagination(string WhereSql, int PageIndex, int PageSize, string Sort, ref int TotalCount)
        {
            return FXFinanceLeaseDAL.FXFinanceLeaseWSBGetPagination(WhereSql, PageIndex, PageSize, Sort, ref  TotalCount);
        }

        #region 报表部份
        /// <summary>
        /// 融资租赁报单情况汇总
        /// </summary>
        /// <returns></returns>
        static public DataTableCollection ReportGetRZZRBD(string sqlwhere)
        {
            return FXFinanceLeaseDAL.ReportGetRZZRBD(sqlwhere);
        }


        /// <summary>
        /// 1 经销商放款台数占比分析
        /// 
        /// </summary>
        /// <returns></returns>
        static public DataTable ReportGetJXSFKTS()
        {
            return FXFinanceLeaseDAL.ReportGetJXSFKTS();
        }

        /// <summary>
        /// 2融资租赁机型占比分析
        /// </summary>
        /// <returns></returns>
        static public DataTable ReportGetRZZRJXZB()
        {
            return FXFinanceLeaseDAL.ReportGetRZZRJXZB();
        }
        /// <summary>
        /// 3融资租赁期限占比分析
        /// </summary>
        /// <returns></returns>
        static public DataTable ReportGetRZZRQXZB()
        {
            return FXFinanceLeaseDAL.ReportGetRZZRQXZB();
        }
        /// <summary>
        /// 4融资租赁同期台数对比分析
        /// </summary>
        /// <returns></returns>
        static public DataTable ReportGetRZZRTQTB()
        {
            return FXFinanceLeaseDAL.ReportGetRZZRTQTB();
        }
        /// <summary>
        /// 5融资租赁同期台数对比分析
        /// </summary>
        /// <returns></returns>
        static public DataTable ReportGetRZZRTQRZTB()
        {
            return FXFinanceLeaseDAL.ReportGetRZZRTQRZTB();
        }
        /// <summary>
        /// 6各年度报单台数（按接单日期确认）（按接单日期 并是从2011年开始）
        /// </summary>
        /// <returns></returns>
        static public DataTable ReportGetGNDBDTS()
        {
            return FXFinanceLeaseDAL.ReportGetGNDBDTS();
        }

        /// <summary>
        ///　经销商逾期单数汇总表
        /// </summary>
        /// <param name="aliseNameWhere">经销商名称　格式为 '''营业一部'',''风险部'''</param>
        /// <returns></returns>
        static public DataTableCollection ReportGetJXSYQFZ(string aliseName,string LeaseCompany, string orderBY)
        {
            return FXFinanceLeaseDAL.ReportGetJXSYQFZ(aliseName,LeaseCompany, orderBY);
        }

        /// <summary>
        /// 管理费收益分析
        ///按经销商区分
        /// </summary>
        /// <returns></returns>
        static public DataTableCollection ReportIncome()
        {
            return FXFinanceLeaseDAL.ReportIncome();
        }
        /// <summary>
        /// 管理费收益分析
        /// 按年份
        /// </summary>
        /// <param name="AliasName"></param>
        /// <returns></returns>
        static public DataTable ReportIncomeByAliasName(string AliasName)
        {
            return FXFinanceLeaseDAL.ReportIncomeByAliasName(AliasName);
        }
        /// <summary>
        /// 管理费收益分析之净收入年对比
        ///经销商按年份
        /// </summary>
        /// <returns></returns>
        static public DataTable ReportIncomeLMFeeIncome()
        {
            return FXFinanceLeaseDAL.ReportIncomeLMFeeIncome();
        }

        /// <summary>
        /// 经销商融资分析报表
        /// </summary>
        /// <param name="AliasName">经销商名称,为空时表示获取所有</param>
        /// <param name="LeaseCompany">融资租赁公司名称</param>
        /// <returns>返回两个表.第一个表,表示:所有的客户信息. 第二个表,表示:6期内的新客户</returns>
        static public DataTableCollection ReportGetRZFXBP(string AliasName, string LeaseCompany)
        {
            return FXFinanceLeaseDAL.ReportGetRZFXBP(AliasName, LeaseCompany);
        }
        /// <summary>
        /// 获取最近一年有发生业务的经销商.
        /// 为经销商融资分析报表提供相关
        /// </summary>
        /// <returns></returns>
        static public DataTable GetAliasNameLastYear(string LeaseCompany)
        {
            return FXFinanceLeaseDAL.GetAliasNameLastYear(LeaseCompany);
        }
        /// <summary>
        /// 经销商逾期2期及以上催收落实
        /// </summary>
        /// <param name="AliasName"></param>
        /// <param name="LeaseCompany"></param>
        /// <returns></returns>
        static public DataTable ReportGetJXSYQ2CSLSBP(string AliasName, string LeaseCompany)
        {
            return FXFinanceLeaseDAL.ReportGetJXSYQ2CSLSBP(AliasName, LeaseCompany);
        }
        /// <summary>
        /// 获取逾期2期以上的经销商
        /// </summary>
        /// <param name="LeaseCompany"></param>
        /// <returns></returns>
        static public DataTable ReportGetAliasNameJXSYQ2CSLSBP(string LeaseCompany)
        {
            return FXFinanceLeaseDAL.ReportGetAliasNameJXSYQ2CSLSBP(LeaseCompany);
        }


        /// <summary>
        /// 经销商逾期2期及以上催收落实 汇总
        /// </summary>
        /// <returns></returns>
        static public DataTableCollection ReportGetJXSYQ2CSLSBPTotal()
        {
            return FXFinanceLeaseDAL.ReportGetJXSYQ2CSLSBPTotal();
        }

         /// <summary>
        /// 9.逾期2期以上客户明累
        /// </summary>
        /// <param name="AliasName"></param>
        /// <returns></returns>
        static public DataTableCollection ReportYQ2QKFMX(string AliasName)
        {
            return FXFinanceLeaseDAL.ReportYQ2QKFMX(AliasName);
        }

        /// <summary>
        /// 9.逾期2期以上客户明累_导出报表用
        /// </summary>
        /// <returns></returns>
        static public DataTable ReportYQ2QKFMXTotal()
        {
            return FXFinanceLeaseDAL.ReportYQ2QKFMXTotal();
        }
        /// <summary>
        /// 获取管理费及首付款报表
        /// </summary>
        /// <param name="sqlwhere"></param>
        /// <returns></returns>
        static public DataTableCollection ReportGetLPayLFMee(string sqlwhere)
        {
            return FXFinanceLeaseDAL.ReportGetLPayLFMee(sqlwhere);
        }
        #endregion
    }
}
